<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib  uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
	<link type="text/css" rel="stylesheet" href="${ctx}/css/style.css" />
    <link rel="stylesheet" type="text/css" href="${ctx}/css/ShopShow.css" />
	<link rel="stylesheet" type="text/css" href="${ctx}/css/MagicZoom.css" />
</head>
<body>

<div class="top">
    <div class="logo"><a href="Index.jsp"><img src="${ctx}/images/logo.png" /></a></div>
    <div class="search">
    	 <form action="CategoryList?action=search&currpage=1" method="post">
            <input type="text" value="" name="keyWord" class="s_ipt">
            <input type="submit" value="搜索" class="s_btn">
        </form>                  
        <span class="fl"><a href="#">咖啡</a><a href="#">iphone 6S</a><a href="#">新鲜美食</a><a href="#">蛋糕</a><a href="#">日用品</a><a href="#">连衣裙</a></span>
    </div>
    <div class="i_car">
    	<div class="car_t">
    	购物车 [
            <span>
                <c:if test="${sessionScope.cart!=null && sessionScope.cart.items.size()>0}">
                    ${sessionScope.cart.items.size()}
                </c:if>
                <c:if test="${sessionScope.cart==null || sessionScope.cart.items.size()<=0}">
                    空
                </c:if>
            </span>]</div>
        <div class="car_bg">
       		<!--Begin 购物车未登录 Begin-->
        	<div class="un_login">还未登录！<a href="Login?action=logout" style="color:#ff4e00;">马上登录</a> 查看购物车！</div>
            <!--End 购物车未登录 End-->
            <!--Begin 购物车已登录 Begin-->
            
	    <c:if test="${not empty sessionScope.user}">
	    <script type="text/javascript">
		    $(function() {
		    	$(".un_login").hide();
			});
	    </script>
		</c:if>
            
            <ul class="cars">
            	<c:forEach items="${sessionScope.cart.items}" var="temp">
                    <li>
                    	<c:set var="cartItem" value="${temp.value }"></c:set>
						<div class="img"><a href="Product?action=details&id=${cartItem.product.id}"><img src="images/files/${cartItem.product.fileName}" width="58" height="58" /></a></div>
                        <div class="name"><a href="Product?action=details&id=${cartItem.product.id}">${cartItem.product.name}</a></div>
                        <div class="price"><font color="#ff4e00">￥${cartItem.product.price}</font> X${cartItem.count}</div>
                    </li>
                </c:forEach>
            </ul>
            <div class="price_sum">共计&nbsp; <font color="#ff4e00">￥</font><span>${sessionScope.cart.sum }</span></div>
            
		<c:if test="${empty sessionScope.user}">
		 		<div class="price_a"><a href="Login?action=logout">去登录</a></div>
		</c:if>
		
		<c:if test="${not empty sessionScope.user}">
		 		<div class="price_a"><a href="cart?action=toSettlement">去购物车结算</a></div>
		</c:if>
            <!--End 购物车已登录 End-->
        </div>
    </div>
</div>
</body>
</html>